home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / animatin / animshp1.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  2.0 KB  |  69 lines  |  [TEXT/ttxt]

  1. --<<<-
  2. -- Filename: ANIMSHP1.SX
  3.  
  4. -- Other Files Required: (none)
  5.  
  6. -- Purpose: To demonstrate how animation works, keeping the 
  7. --     target list unchanged -- that is, without using
  8. --     TargetListAction 
  9.  
  10. -- Specialized Classes: (none)
  11.  
  12. -- Instructions to User: Load this file; it displays a window,
  13. --     which is initially empty, then displays a 2D shape that 
  14. --       changes from a cirle to a rounded rectangle to a rectangle.
  15. --     To start again, type: "goToBegin alp"
  16.  
  17. -- Author: Douglas Kramer
  18.  
  19. ------------------------------------------------------------------------ 
  20.  
  21. -- Create a window
  22. global myWindow := new Window boundary:(new Rect x2:200 y2:200)
  23. myWindow.y := 40
  24. show myWindow
  25.  
  26. -- Create the ActionList and ActionListPlayer
  27. global al := new ActionList
  28. global alp := new ActionListPlayer actionList:al scale:30 targetCount:24
  29.  
  30. -- Create a blue circle and add it to the window and targets list
  31. global myShape := new TwoDShape target:(new Oval x2:80 y2:80) 
  32. myShape.fill := new Brush color:blueColor
  33. myShape.x := 60
  34. myShape.y := 60
  35. append myWindow myShape
  36.  
  37. -- Puts the shape on the target list
  38. alp.targets[1] := myShape
  39.  
  40. -- Set an action to hide the shape at time 0
  41. global hideShape := new ScriptAction script:(a t p -> hide t) targetnum:1 time:0
  42.  
  43. -- Set an action to show the shape at time 1
  44. global showShape := new ScriptAction script:(a t p -> show t) targetnum:1 time:1
  45.  
  46. -- Set an action to set the shape to an oval
  47. global makeOval := new ShapeAction targetNum:1 time:1 \
  48.                                     shape:(new Oval x2:80 y2:80) 
  49.  
  50. -- Set an action to change its shape
  51. global makeRoundRect := new ShapeAction targetNum:1 time:30 \
  52.                                     shape:(new RoundRect x2:80 y2:80 rx:30 ry:30)
  53.  
  54. -- Set another action to change its shape
  55. global makeRect := new ShapeAction targetNum:1 time:60 \
  56.                                     shape:(new Rect x2:80 y2:80)
  57.  
  58. -- Append actions to the ActionList
  59. append al hideShape
  60. append al showShape
  61. append al makeOval
  62. append al makeRoundRect
  63. append al makeRect
  64.  
  65. -- Play the ActionListPlayer
  66. play alp
  67.  
  68. -- To play again, type: goToBegin alp
  69.